#!/bin/bash

# prepare
cd /root/ocean
source /root/miniconda3/bin/activate && conda init
conda install git -y
pip install gil
gil update

build_package(){
    echo "build python" $1 " package"
    conda remove -n python$1 --all -y
    conda create -n python$1 python=$1 -y
    conda activate python$1
    conda install cmake=3.19 gcc_linux-64=9.3.0 gxx_linux-64=9.3.0 make libuuid git -y

    # mkdir workspace
    cd /root/ocean
    rm -rf build
    mkdir build
    mkdir build/gpu

    # build gpu lib
    cd build/gpu
    cmake -DOCEAN_ENABLE_CUDA=ON ../../
    make pyocean -j24
    cd ../../ocean/src/python/
    python3 setup.py bdist_wheel
    cp dist/*  /root/ocean/packages/
}

build_package 3.7
build_package 3.8
build_package 3.9
build_package 3.10